package com.seguriapp.util;

import java.util.List;

import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;
import com.seguriapp.entities.Entity;

/**
 * TODO(pjohnson): Insert description
 * 
 * @author Pablo Johnson (pablo.88j@gmail.com)
 */
public class EntityOverlay extends ItemizedOverlay<OverlayItem> {

	private List<Entity> overlayItems;
	private Activity mContext;

	public EntityOverlay(final Activity context, final Drawable drawable,
			final List<Entity> items) {
		super(boundCenter(drawable));
		mContext = context;
		overlayItems = items;
		populate();
	}

	@Override
	protected OverlayItem createItem(final int index) {
		return null;// overlayItems.get(index);
	}

	@Override
	public int size() {
		return overlayItems.size();
	}

	public void addItems(final Entity item) {
		overlayItems.add(item);
		populate();
	}

	@Override
	protected boolean onTap(int index) {
		final Entity item = (Entity) overlayItems.get(index);
		// showCrimeDialog(item);
		return super.onTap(index);
	}

	private void showCrimeDialog(final Entity item) {
		final FragmentManager fm = ((FragmentActivity) mContext)
				.getSupportFragmentManager();
		// final CrimeDialog crimeDialog = new CrimeDialog(item);
		// crimeDialog.show(fm, "fragment_edit_name");
	}

}
